package top.kaoshanji.p1ch12d;

import java.lang.reflect.InvocationHandler;

/**
 * 代码清单-p1ch12d-133页a：具体业务的动态代理
 * @author kaoshanji
 * ^_^
 * create time 2025/3/22 19:23
 */
public class SubjectDynamicProxy extends DynamicProxy {

    public static  <T> T newProxyInstance(Subject subject) {

        // 获得 ClassLoader
        ClassLoader loader = subject.getClass().getClassLoader();

        // 获得接口数组
        Class<?>[] classes = subject.getClass().getInterfaces();

        // 获得 handler
        InvocationHandler handler = new MyInvocationHandler(subject);

        return newProxyInstance(loader, classes, handler);

    }


}
